local awful   = require("awful")
local naughty = require("naughty")
require("main.vars")

before = ""

function get_bef(a)
    before = a
end

function update_brightness(comm)
    awful.spawn.easy_async_with_shell("xrandr --verbose | awk '/Brightness/ { print $2; exit }'", function(out) get_bef(out) end)
    local state = tonumber(string.sub(before, 0, string.len(before) - 1))

    naughty.notify({text = tostring(state)})

    if ((comm == "+") and (state < 1.0)) then
        state = state + 0.1
    elseif ((comm == "-") and (state >= 0.1)) then
        state = state - 0.1
    end
    awful.spawn("xrandr --output " .. intScr .. " --brightness " .. state)
end
